package eagle.im.client;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;

/**
 * @Program : eagle-im
 * @ClassName : ClientDemo
 * @Description :
 * @Date: 2021-12-20 18:55
 * @Version : 1.0
 */
public class ClientDemo {

    public void init(){
        EventLoopGroup loopGroup = new NioEventLoopGroup();

        try {
            Bootstrap bootstrap = new Bootstrap();
            bootstrap.group(loopGroup).channel(NioSocketChannel.class).handler(new ClientInitializer());

            ChannelFuture future = null;
            try {
                future = bootstrap.connect("localhost", 8899).sync();
                future.channel().closeFuture().sync();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        } finally {
            loopGroup.shutdownGracefully();
        }
    }

    public static void main(String[] args) {
        new ClientDemo().init();
    }

}
